//
//  Skill.m
//  CandyJump
//
//  Created by Bon Lam on 03/07/2011.
//  Copyright 2011 Peru Republic. All rights reserved.
//

#import "Skill.h"
#import "Skill+ProtectedMethods.h"

#define SKILL_TYPE_JUMP_BOOST_STR					@"JUMP_BOOST"
#define SKILL_TYPE_MAGNET_STR						@"STAR_MAGNET"
#define SKILL_TYPE_PLATFORM_BUILDER_STR				@"PLATFORM_BUILDER"
#define SKILL_TYPE_BUBBLE_STR						@"BUBBLE"
#define SKILL_TYPE_IMMUNE_STR						@"IMMUNE"
#define SKILL_TYPE_TELEPORT_STR						@"TELEPORT"
#define SKILL_TYPE_ROCKET_STR						@"ROCKET"

//=====================================================================================================================
@implementation Skill

@synthesize skillCode;
@synthesize skillType;
@synthesize displayName;
@synthesize buffCodeArray;

#pragma mark Skill - Initialization
//---------------------------------------------------------------------------------------------------------------------
- (id)init
{
	self = [super init];
	if (self == nil) {return self;}
	
	buffCodeArray = [[NSMutableArray alloc] init];
	
	return self;
}

//---------------------------------------------------------------------------------------------------------------------
- (void)dealloc
{
	[skillCode release];
	skillCode = nil;
	
	[displayName release];
	displayName = nil;
	
	[buffCodeArray release];
	buffCodeArray = nil;
	
	[super dealloc];
}

//---------------------------------------------------------------------------------------------------------------------
- (id)copyWithZone:(NSZone *)zone
{
	Skill *newSkill = [[[self class] allocWithZone:zone] init];
	
	newSkill.skillCode = self.skillCode;
	newSkill.skillType = self.skillType;
	newSkill.displayName = self.displayName;
	
	return newSkill;
}

#pragma mark Skill - Static Functions
//---------------------------------------------------------------------------------------------------------------------
+ (SKILL_TYPE) skillTypeByString:(NSString *)str;
{
	if ([str isEqualToString:SKILL_TYPE_JUMP_BOOST_STR] == YES) {return SKILL_TYPE_JUMP_BOOST;}
	if ([str isEqualToString:SKILL_TYPE_MAGNET_STR] == YES) {return SKILL_TYPE_MAGNET;}
	if ([str isEqualToString:SKILL_TYPE_PLATFORM_BUILDER_STR] == YES) {return SKILL_TYPE_PLATFORM_BUILDER;}
	if ([str isEqualToString:SKILL_TYPE_BUBBLE_STR] == YES) {return SKILL_TYPE_BUBBLE;}
	if ([str isEqualToString:SKILL_TYPE_IMMUNE_STR] == YES) {return SKILL_TYPE_IMMUNE;}
	if ([str isEqualToString:SKILL_TYPE_TELEPORT_STR] == YES) {return SKILL_TYPE_TELEPORT;}
	if ([str isEqualToString:SKILL_TYPE_ROCKET_STR] == YES) {return SKILL_TYPE_ROCKET;}
	return SKILL_TYPE_JUMP_UNDEFINED;
}

@end
